package cn.itsource.org.domain;

import cn.itsource.basic.domain.baseDomain;
import cn.itsource.basic.util.CreatePassword;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "t_user")
public class User extends baseDomain implements CreatePassword {
   /**
    * 规则解耦
    */
   public interface PhoneRegister{}
   public interface EmailRegister{}
   private String username;
   @NotBlank(message = "邮箱不能为空",groups = {EmailRegister.class})
   private String email;
   @NotBlank(message = "手机号为空",groups = {PhoneRegister.class})
   private String phone;
   private String salt;
   @NotBlank(message = "密码不能为空",groups = {PhoneRegister.class,EmailRegister.class})
   @Size(min = 3,message = "密码最少3位",groups = {PhoneRegister.class,EmailRegister.class})
   private String password;
   @Transient
   private String code;
   @Transient
   private  String confirmPassword;
   private Integer state;
   private Integer age;
   @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
   private Date createtime = new Date();
   private String headImg;

}
